﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Medical.Business;
using Medical.Entity;

public partial class control_FaqSort : System.Web.UI.UserControl
{
    protected DataTable dtSort = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    /// <summary>
    /// 数据初始化
    /// </summary>
    protected void InitData()
    {
        dtSort = new BisSortInfo().GetAllSortList(ArticelTypeEnum.FeedBack);
        rptSort.DataSource = Until.CreateNewDT(dtSort, dtSort.Select("ParentID=0"));
        rptSort.DataBind();
    }

    /// <summary>
    /// 列表绑定处理
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void rptSort_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DataTable dt = (DataTable)((Repeater)sender).DataSource;
        if (dtSort != null && dtSort.Rows.Count > 0)
        {
            Repeater rptSubSort = e.Item.FindControl("rptSubSort") as Repeater;
            DataTable dtNew = dtSort.Clone();
            DataRow[] drList = dtSort.Select("ParentID=" + dt.Rows[e.Item.ItemIndex]["ID"].ToString());
            for (int i = 0; i < drList.Length; i++)
            {
                DataRow drTem = dtNew.NewRow();
                foreach (DataColumn column in dt.Columns)
                {
                    drTem[column.ColumnName] = drList[i][column.ColumnName];
                }
                dtNew.Rows.Add(drTem);
            }
            rptSubSort.DataSource = dtNew;
            rptSubSort.DataBind();
        }
    }
}